import axios from "axios"
const service = axios.create({
    baseURL:"http://localhost:8080",
    timeout:10000
})
// 请求拦截
service.interceptors.request.use(function(config){
    console.log(config);
    console.log(sessionStorage.getItem("token"));
    config.headers["Content-Type"] = "application/json";
    config.headers["Authorization"] = `Bearer ${sessionStorage.getItem("token")}`;
    return config;
},function(error){
    return Promise.reject(error)
})
// 响应拦截
service.interceptors.response.use(function(response){
    // console.log(response);
    // switch (response.status) {
    //     case 200:
    //         console.log("请求成功");
    //         break;
    //     case 404:
    //         console.log("错误信息404");
    //         break;
    //     default:
    //         break;
    // }
    return response
},function(error){
    return Promise.reject(error)
})
export default service;
